package com.lagou.mr.nc;

import com.lagou.mr.wc2.WordCount2Driver;
import com.lagou.mr.wc2.WordCount2Mapper;
import com.lagou.mr.wc2.WordCount2Reducer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.CombineTextInputFormat;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class NumberSortDriver {

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        final Configuration conf = new Configuration();
        final Job job = Job.getInstance(conf, "NumberSortDriver");
        job.setJarByClass(NumberSortDriver.class);
        job.setMapperClass(NumberSortMapper.class);
        job.setReducerClass(NumberSortReducer.class);
        job.setMapOutputKeyClass(IntWritable.class);
        job.setMapOutputValueClass(NullWritable.class);
        job.setOutputKeyClass(IntWritable.class);
        job.setOutputValueClass(IntWritable.class);
        CombineTextInputFormat.setMaxInputSplitSize(job, 41943040);
        FileInputFormat.setInputPaths(job, new Path("G:\\dashuju\\data\\ns"));
        FileOutputFormat.setOutputPath(job, new Path("G:\\dashuju\\output\\ns"));
        final boolean flag = job.waitForCompletion(true);
        System.exit(flag ? 0 : 1);
    }
}
